const path = require("path");

const resolve = dir => path.resolve(__dirname, dir);
const BASE_URL = process.env.NODE_ENV === 'production'
  ? '/reactzh'
  : '/reactzh'
module.exports = {
  devServer: {
    open: false,
    port: 9999,
    proxy: {
      '/collegeapi': {
        target: 'xxxxxxxx', // 这个是地址不要乱操作
        secure: false, // 不写这个会报错 代理失败 Error occurred while trying to proxy:
        changOrigin: true
      },
    }
  },
  webpack: {
    alias: {
      "@": resolve("src"),
      "components": resolve("src/components")
    },
    configure: (webpackConfig, {
      env, paths
    }) => {
      // paths.appPath='public'
      paths.appBuild = 'build'
      webpackConfig.output = {
        ...webpackConfig.output,
        // ...{
        //   filename: whenDev(() => 'static/js/bundle.js', 'static/js/[name].js'),
        //   chunkFilename: 'static/js/[name].js'
        // },
        path: path.resolve(__dirname, 'build'), // 修改输出文件目录
        publicPath: BASE_URL
      }
      return webpackConfig
    }
  }
}
